package com.astrob.model;

import com.astrob.NavFrameSDK.POIDescription;
import com.astrob.naviframe.Start;

import java.util.Comparator;

public class SortByDistance implements Comparator {
	public int compare(Object o1, Object o2) {
		POIDescription p1 = (POIDescription) o1;
		POIDescription p2 = (POIDescription) o2;
		LonLat center = Start.getInstance().MapKit().getMapCenter();

		if (Start.getInstance().MapKit().getDistance(center,
				new LonLat(p1.position.lon, p1.position.lat)) > Start
				.getInstance().MapKit().getDistance(center,
						new LonLat(p2.position.lon, p2.position.lat))) {

			return 1;
		}
		return 0;
	}
}
